package com.mzy.datepackage.M2022.July.tentwo;

import com.mzy.datepackage.M2022.Jun.TenThree.object;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author mzy
 * @Date 2022/7/12 14:49
 * @Version 1.0
 */
public class test {

    /**
     * Stream流中间处理问题
     */

    public static void main(String[] args) {
        ArrayList<String> objects = new ArrayList<>();
        objects.add("nameserver 114.114.114.114");
        objects.add("nameserver 8.8.8.8");
        objects.add("nameserver 8.8.4.4");

        for (int i = 0; i < objects.size(); i++) {
            if (objects.get(i).contains("8.8.8.8")) {
                String asdsa = objects.get(i).replaceAll("\\s[\\D\\d]*", " 8888888888888888");
                objects.set(i,asdsa);
                break;
            }
        }
        objects.forEach(e-> System.out.println(e));


        for (int i = 0; i < objects.size(); i++) {
            if (objects.get(i).contains("88888888888888")) {
                objects.remove(objects.get(i));
                break;
            }
        }

        objects.forEach(e-> System.out.println(e));


        ArrayList<Animals> animals = new ArrayList<>();
        animals.add(new Animals("小黄",5));
        animals.add(new Animals("小白",8));
        animals.add(new Animals("小黑",3));
        animals.add(new Animals("小绿",9));


        List<Animals> white = animals.stream().filter(e -> e.getAge().equals(3) || e.getName().contains("白")).collect(Collectors.toList());
        white.forEach(e -> System.out.println(e));


        System.out.println("测试");
    }
}
